package com.hzqdn.monsterjudge.codesandbox;


import com.hzqdn.monsterjudge.codesandbox.impl.AICodeSandbox;
import com.hzqdn.monsterjudge.codesandbox.impl.ExampleCodeSandbox;
import com.hzqdn.monsterjudge.codesandbox.impl.RemoteCodeSandbox;
import com.hzqdn.monsterjudge.codesandbox.impl.ThirdPartyCodeSandbox;
import com.hzqdn.monsterjudge.config.SpringContextUtils;

/**
 * 代码沙箱工厂（根据字符串参数创建指定的代码沙箱实例），
 */
public class CodeSandboxFactory {

    /**
     * 创建代码沙箱实例
     */
    public static CodeSandbox newInstance(String type) {
        return switch (type) {
            case "example" -> new ExampleCodeSandbox();
            case "remote" -> new RemoteCodeSandbox();
            case "thirdParty" -> new ThirdPartyCodeSandbox();
            case "ai" -> SpringContextUtils.getBean(AICodeSandbox.class);
            default -> new ExampleCodeSandbox();
        };
    }
}
